package zmee.wchn;

import kd.bos.ksql.util.StringUtil;
import kd.bos.print.core.data.DataRowSet;
import kd.bos.print.core.data.datasource.PrtDataSource;
import kd.bos.print.core.data.field.CollectionField;
import kd.bos.print.core.data.field.Field;
import kd.bos.print.core.data.field.TextField;
import kd.bos.print.core.plugin.AbstractPrintPlugin;
import kd.bos.print.core.plugin.event.AfterLoadDataEvent;
import kd.bos.print.core.plugin.event.BeforeOutputWidgetEvent;

import java.util.List;

public class AfterPringPlugin extends AbstractPrintPlugin {
    @Override
    public void beforeOutputWidget(BeforeOutputWidgetEvent evt) {
        super.beforeOutputWidget(evt);
        String widgetKey = evt.getWidgetKey();
//        if (StringUtil.equals("Text",widgetKey)){
//            evt.setOutputValue(new TextField("测试修改内容"));
//        }

    }

    @Override
    public void afterLoadData(AfterLoadDataEvent evt) {
        super.afterLoadData(evt);
        List<DataRowSet> dataRowSets = evt.getDataRowSets();
        PrtDataSource dataSource = evt.getDataSource();

        String dsName = dataSource.getDsName();
        for (DataRowSet dataRowSet : dataRowSets) {
            Field text1 = dataRowSet.getField("ces1");
            CollectionField layoutGrid1 = dataRowSet.getCollectionField("LayoutGrid1");
            text1.setValue("ceswenb");
            dataRowSet.add("Text24",new TextField("测试修改内容"));
//            dataRowSet.put("Text22",new TextField("测试修改内容"));


        }


    }
}
